package com.bailiban.repository;

import com.bailiban.entity.News;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


/**
 * @author zhulang
 * @Classname NewsRepository
 * @Description TODO
 * @Date 2020/4/1 14:54
 */
public interface NewsRepository extends JpaRepository<News,Integer> {
    /**
     * 查询指定条目的最新消息
     * @param size
     * @return
     */
    @Query(value = "select * from tab_news order by timestamp desc limit ?1 ",nativeQuery = true)
    List<News> findLatestNews(Integer size);

    /**
     * 查询指定报社下的所有新闻
     * @param source
     * @return
     */
    List<News> findBySource(String source);
}
